home *** CD-ROM | disk | FTP | other *** search
/ Trading on the Edge / Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin / pc / mac_file / vendor_d / neuralwa / nw2v50 / boltzio.nnc < prev    next >
Text File  |  1993-08-23  |  6KB  |  150 lines

  1. csv3.1    ! Control Strategy Version 3.1 - Boltzmann I/O model
  2. L_saRi_a    cset    recall,0        ! Initialize Recall Counter
  3. !
  4. !
  5. ! Read input.  Assume 1 = ON, -1 = OFF, 0 = doesn't matter.
  6. ! Note: In I/O model there will typically be no 0's.
  7. !
  8. L_saRi_a    lset    in,0            ! Input layer
  9. L___Ri_a    io    read            ! Recall Input
  10. L_saR___    io    lrnin            ! Learn Input
  11. !
  12. ! Propagate raw inputs in order to flag clamped units. Clamped
  13. ! units are flagged in the hidden layer by means of a non-zero
  14. ! current error term.  Note: "set" operation zeros out all hidden units
  15. ! which don't have set connections.
  16. !
  17. L_saRi_a    lset    in,1            ! Boltzmann layer
  18. L_saRi_a    math    set|w=i|e=w|fire    ! Inject Input
  19. !
  20. ! Read desired output - I/O model and phase+ only.
  21. ! Back-propagate raw errors to flag clamped units.
  22. !
  23. L_saR_sa    lset    out,0            ! Output layer
  24. L_saR___    io    lrnout            ! Desired Output
  25. L___R_sa    io    rcltst            ! Desired Output (Test)
  26. L_saR___    math    backp|fire        ! Backprop output
  27. !
  28. ! At this point, the error fields of the hidden layer units are
  29. ! non-zero if and only if unit is clamped; transfer this to
  30. ! current error field and then process inputs (and desired outputs) and
  31. ! and initialize hidden unit activations.
  32. !
  33. L_saRi_a    lset    in,0            ! Input Layer
  34. L_saRi_a    math    tran|output|fire    ! 1,-1's to 1,0's
  35. L_saRi_a    lset    in,1            ! Boltzman layer
  36. L_saRi_a    math    set|w=i|ce=e|e=w|fire    ! Read true inputs
  37.  
  38. L_saR___    lset    out,0            ! Output Layer
  39. L_saR___    math    tran|output|e=w|backp|fire ! True outputs
  40. !
  41. ! Error fields of hidden layer units now contain proper values (0's or
  42. ! 1's) for the clamped units, and 0's for the unclamped units.
  43. ! Transfer these values to the tran field using "e=w" and "tran". The
  44. ! "e=w" operation will transfer the proper clamped values; the "tran"
  45. ! operation will not affect the clamped values but will randomize the
  46. ! unclamped values ( assuming a non zero noise ) to be 0 or 1 with
  47. ! equal probability ( see Boltzman transfer function ).
  48.  
  49. L_saRisa    lset    in,1            ! Boltzman layer
  50. L_saRi_a    math    i=e|w=e|tran|output|rnoise|e=0|fire
  51. L_saRi_a    cadd    recall,1        ! Increment Recall counter
  52. !
  53. ! Annealing for phase+ and recall
  54. !
  55. @ann1        ! "Iteration" loop, indexed by recall counter
  56. L_saR_sa    fcmp    lflag,eors        ! End of recall schedule?
  57. L_saR___    banz    @stats1            ! Collect statistics (Learn!)
  58. L___R_sa    banz    @wrapup            ! wrap up cycle
  59. L_saR_sa    fcmp    lflag,ueors        ! User End of recall schedule?
  60. L_saR_sa    banz    @end
  61. L_saR_sa    cset    wrk1,aux2        ! Initialize inner loop
  62. @ann2        ! Inner loop - # math steps per iteration
  63. L_saR_sa    math    sum|tran|rnoise|output|setb ! Fire
  64. L_saR_sa    csub    wrk1,1            ! Decrement Inner counter
  65. L_saR_sa    ccmp    wrk1,0
  66. L_saR_sa    bgt    @ann2
  67. L_saR_sa    cadd    recall,1        ! Increment Recall counter
  68. L___R_s_    eos                ! End of recall step
  69. L_saR__a    br    @ann1            ! Continue recall
  70. !
  71. @stats1        ! Now accumulate co-occurrence statistics for phase+
  72. L_saR___    cset    wrk2,aux3        ! Initialize outer loop
  73. @stats2
  74. L_saR___    cset    wrk1,aux2        ! Initialize inner loop
  75. @stats3    ! Inner stats loop - # math steps per iteration
  76. L_saR___    math    sum|tran|lnoise|output|setb ! Fire
  77. L_saR___    csub    wrk1,1            ! Decrement Inner counter
  78. L_saR___    ccmp    wrk1,0
  79. L_saR___    bgt    @stats3
  80. L_saR___    math    learn|setb|fire        ! Accumulate stats
  81. L_saR___    cadd    recall,1        ! Increment Recall counter
  82. L_saR___    csub    wrk2,1            ! Decrement Outer counter
  83. L_saR___    ccmp    wrk2,0
  84. L_saR___    bgt    @stats2            ! Continue stats
  85. !
  86. ! If end of phase+ go on to do phase-
  87. ! Do clamping again.  For I/O version of the Boltzman machine, this
  88. ! entails unclamping the "output" units.
  89. !
  90. L_saR___    cset    recall,0        ! Initialize Recall Counter
  91. L_saR___    lset    in,0            ! Input Layer
  92. L_saR___    math    w=i|output|fire        ! Raw inputs
  93. L_saR___    lset    in,1            ! Boltzmann layer
  94. L_saR___    math    set|w=i|e=w|fire    ! Inject Input
  95. !
  96. ! Read input info again, save clamping info in "ce" field,
  97. ! initialize clamped units, and randomize non-clamped units.
  98. !
  99. L_saR___    lset    in,0            ! Input Layer
  100. L_saR___    math    tran|output|fire    ! 1,-1's to 1,0's
  101. L_saR___    lset    in,1            ! Boltzman layer
  102. L_saR___    math    set|w=i|ce=e|tran|output|rnoise|e=0|fire
  103. L_saR___    cadd    recall,1        ! Increment Recall counter
  104. !
  105. ! Annealing for phase-
  106. !
  107. @ann3    ! "Iteration" loop, indexed by recall counter
  108. L_saR___    fcmp    lflag,eors        ! End of recall schedule?
  109. L_saR___    banz    @stats4            ! Collect statistics (Learn!)
  110. L_saR___    fcmp    lflag,ueors        ! User End of recall schedule?
  111. L_saR___    banz    @end            ! Collect statistics (Learn!)
  112. L_saR___    cset    wrk1,aux2        ! Initialize inner loop
  113. @ann4        ! Inner loop - # math steps per iteration
  114. L_saR___    math    sum|tran|rnoise|output    ! Fire
  115. L_saR___    csub    wrk1,1            ! Decrement Inner counter
  116. L_saR___    ccmp    wrk1,0
  117. L_saR___    bgt    @ann4
  118. L_saR___    cadd    recall,1        ! Increment Recall counter
  119. L_saR___    br    @ann3            ! Continue recall
  120. !
  121. @stats4        ! Now accumulate co-occurrence statistics for phase-
  122. L_saR___    cset    wrk2,aux3        ! Initialize outer loop
  123. @stats5
  124. L_saR___    cset    wrk1,aux2        ! Initialize inner loop
  125. @stats6    ! Inner stats loop - # math steps per iteration
  126. L_saR___    math    sum|tran|lnoise|output    ! Fire
  127. L_saR___    csub    wrk1,1            ! Decrement Inner counter
  128. L_saR___    ccmp    wrk1,0
  129. L_saR___    bgt    @stats6
  130. L_saR___    math    learn|fire        ! Accumulate stats
  131. L_saR___    cadd    recall,1        ! Increment Recall counter
  132. L_saR___    csub    wrk2,1            ! Decrement Outer counter
  133. L_saR___    ccmp    wrk2,0
  134. L_saR___    bgt    @stats5            ! Continue stats
  135.  
  136. ! Special call to learn with wrk2 = 0, instructing learn
  137. ! function to actually update the weights if at the end
  138. ! of an epoch
  139. L_saR___    math    learn|fire        ! Accumulate stats
  140. !
  141. ! Show output etc
  142. !
  143. @wrapup
  144. L_saR_sa    lset    out,0            ! Output layer
  145. L___R_sa    math    sum|ce=e|tran|output|e-=w|swap  !15 Recall output
  146. L_saR___    math    sum|tran|output|fire    ! Learn output
  147. L_saR___    io    lrnrslt            ! Show learn result
  148. L___R_sa    io    write            ! Show Recall Output
  149. @end
  150.